package fx;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class HelloController {

    @FXML
    private TextField firstNameField;
    @FXML
    private TextField lastNameField;
    @FXML
    private Label messageLabel;

    private boolean isEmpty(String s) {
        return s == null || s.equals("");
    }

    public void sayHello() {

        String firstName = firstNameField.getText();
        String lastName = lastNameField.getText();


        String s = "";

        if (!isEmpty(firstName))
            s += firstName;


        if (!isEmpty(lastName)) {
            if (s.length() > 0)
                s += " ";
            s += lastName;
        }

        messageLabel.setText("Hello " + (s.length() > 0 ? s : "mysterious person"));

    }

}
